//
//  DoctorDetailViewController.m
//  安好
//
//  Created by 冯凯 on 14-12-4.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "DoctorDetailViewController.h"
#import "HospitalDetailTableViewCell.h"
#import "IllnessTableViewCell.h"
#import "HosDetailTableViewCell.h"
#import "DepartmentListViewController.h"
#import "HosPCommentListViewController.h"
#import "RegexKitLite.h"
#import "PopoverView.h"
#import "NearbyPathViewController.h"
#import "DepartmentViewController.h"
//点击医生--
#import "RegDoctorListViewController.h"
//我要点评--医院
#import "EncyMyCommentViewController.h"
@interface DoctorDetailViewController ()<UIActionSheetDelegate>

@end

@implementation DoctorDetailViewController
{
    NSArray *telArray;
    NSArray *titles;
    NSArray *images;
    NSArray *selectArray;
    PopoverView *pop;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    telArray=[[NSArray alloc]init];
    [self makeNavBar];
    titles = @[@"收藏", @"分享"];
    images = @[@"百科_收藏", @"百科_分享"];
    selectArray=@[@"百科_收藏成功", @"百科_分享成功"];
    [self viewWithTableView];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [pop dismiss:YES];
}
- (void)viewWillAppear:(BOOL)animated
{
    [self viewWithData];
}
- (void)viewWithTableView
{
    self.illnessTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, kScreenWidth, kScreenHeight - iOS7TopMargin) style:UITableViewStylePlain];
    self.illnessTableView.delegate = self;
    self.illnessTableView.dataSource = self;
    self.illnessTableView.backgroundColor=[ClassMethodsViewController colorWithHexString:BACK_BACKGROUNDCOLOR_16];

    self.illnessTableView.showsHorizontalScrollIndicator = NO;
    self.illnessTableView.showsVerticalScrollIndicator = NO;
    [self.illnessTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];//去掉系统的分割线
    [self.view addSubview:self.illnessTableView];
    
}
-(void)makeNavBar
{
    self.navigationItem.title = @"医院详情";
    // “返回”
    UIBarButtonItem *backBtnItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_返回.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBackDown)];
    backBtnItem.tintColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = backBtnItem;
    // “筛选”
    UIButton *rightButtonMore = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButtonMore.frame = CGRectMake(0,0, 23, 23);
    [rightButtonMore setImage:[UIImage imageNamed:@"公用_更多.png"] forState:UIControlStateNormal];
    [rightButtonMore addTarget:self action:@selector(showListView:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:rightButtonMore];
}
//筛选
- (void)showListView:(UIButton *)sender
{
    CGPoint point = CGPointMake(sender.frame.origin.x + sender.frame.size.width/2, 64);
    pop=[[PopoverView alloc]initWithPoint:point titles:titles images:images selectImage:selectArray];
    pop.selectRowAtIndex = ^(NSInteger index){
        MyNSLog("select index:%d", index);
        switch (index) {
            case 0:
            {
                MyNSLog("第一个");
                if ([[titles objectAtIndex:0] isEqualToString:@"收藏"]) {
                    [self collection];
                }
                else
                {
                    [self deleteCollection];
                }
            }
                break;
            case 1:
            {
                [self showShareView];
            }
                break;
                
            default:
                break;
        }
    };
    [pop show];
}
#pragma mark 实现share方法，通过点击的视图的tag值判断是什么类型的分享
- (void)share:(UITapGestureRecognizer *)shareTap{
    NSString * url= [NSString stringWithFormat:@"http://m.niruoanhao.com/share/hospital/%@",self.diseaseid];
    NSString * title = @"安好，准确掌握全国医院信息，快速检索查询";
    NSString * text = @"提供全国2万家医院的电话、地址、科室及医院医生信息";
    UIImage * image = [UIImage imageNamed:@"二维码"];
    switch (shareTap.view.tag) {
        case 11:{//微信
            [self weixinShare:url :title :text :image];
        }
            break;
        case 12:{//朋友圈
            [self weixinFriendShare:url :title :text :image];
        }
            break;
        case 13:{//短信
            [self showSMSPicker:url :title :text :nil];
        }
            break;
        case 14:{//QQ
            [self qqShare:url :title :text :image];
        }
            break;
        case 15:{//QQ空间
            [self qqZoneShare:url :title :text :image];
        }
            break;
        case 16:{//新浪微博
            [self sinaWeiboShare:url :title :text :image];
        }
            break;
            
        default:
            break;
    }
}
- (void)Login
{
    NSString *postURL=[NSString stringWithFormat:@"%@collection/addCollection",kBaseURL];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *dict=@{
                         @"platform":kPlatform,
                         @"version":kVersion,
                         @"title":self.navigationItem.title,
                         @"objectid":self.diseaseid,
                         @"type":@"2",
                         };
    [manager POST:postURL parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [self hiddenActionView];
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        if ([statusString isEqualToString:@"0"]) {
        }
        else{
            [self showCustomHudSingleLine:@"收藏成功"];
            titles = @[@"已收藏", @"分享"];
            images = @[@"百科_收藏成功", @"百科_分享"];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self hiddenActionView];
    }];

}
- (void)collection
{
    [self isLogin];
}
- (void)deleteCollection
{
    [self showActionView];
    NSString *postURL=[NSString stringWithFormat:@"%@collection/delete/",kBaseURL];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *dict=@{
                         @"platform":kPlatform,
                         @"version":kVersion,
                         @"objectid":self.diseaseid,
                         @"type":@"2",
                         };
    [manager POST:postURL parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        [self hiddenActionView];
        if ([statusString isEqualToString:@"0"]) {
        }
        else{
            [self showCustomHudSingleLine:@"取消收藏"];
            titles = @[@"收藏", @"分享"];
            images = @[@"百科_收藏", @"百科_分享"];

        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self hiddenActionView];
    }];
}

//返回 百科页面
-(void)leftBackDown
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewWithData
{
    [self showActionView];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]initWithCapacity:10];
    
    [dict setObject:kPlatform forKey:@"platform"];
    [dict setObject:kVersion forKey:@"version"];
    [dict setObject:self.diseaseid forKey:@"hospitalid"];
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:[NSString stringWithFormat:@"%@wiki/hospitalDetailInfo/",kBaseURL] parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        [self hiddenActionView];
        if ([statusString isEqualToString:@"0"]) {
            
        }else{
            self.diseaseDic = [NSDictionary dictionaryWithDictionary:responseObject];
            NSString *iscollection=[NSString stringWithFormat:@"%@",[[self.diseaseDic valueForKey:@"data"] valueForKey:@"iscollection"]];

            if ([iscollection isEqualToString:@"0"]) {
                titles = @[@"收藏", @"分享"];
                images = @[@"百科_收藏", @"百科_分享"];

            }else
            {
                titles = @[@"已收藏", @"分享"];
                images = @[@"百科_收藏成功", @"百科_分享"];

            }
            self.isload = YES;
            [self.illnessTableView reloadData];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self hiddenActionView];
    }];
    
}
#pragma mark 2中cell的加载
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.isload == YES) {
        if (section == 0){
            return 1;
        }else if (section == 1){
            return 2;
        }else if (section == 2){
            return 1;
        }else{
            return 3;
        }
    }else{
        return 0;
    }
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 2) {
        static NSString * identifier = @"myCell";
        
        //  检测、查询是否有闲置的单元格
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        if (cell == nil){
            cell =  [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        if (indexPath.row == 0) {
        UILabel * causelabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 15,kScreenWidth-15*2 , 20) text:[[self.diseaseDic objectForKeyedSubscript:@"data"] objectForKey:@"introduction"]font:[UIFont systemFontOfSize:LABEL_FONT_SIZE_CONTENT_13] textColor:[UIColor darkGrayColor] backgroundColor:[UIColor clearColor] numberOfLines:0 lineSpacing:6];
            [cell addSubview:causelabel];
            
        UIImageView * dowmImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, causelabel.height + 29, kScreenWidth, 0.5)];
            dowmImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
            [cell addSubview:dowmImageView];
            [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
            UIImageView * upImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth , 0.5)];
            upImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
            [cell addSubview:upImageView];
        }
        UIImageView * upImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 0, kScreenWidth-15 , 0.5)];
        upImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
        [cell addSubview:upImageView];
        return cell;
    }
    else if (indexPath.section == 1){
        IllnessTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IllnessTableViewCell"];
        if (cell == nil) {
            if (kScreenWidth == 414){
                
                cell = [[[NSBundle mainBundle] loadNibNamed:@"IllnessTableViewCell" owner:self options:nil] lastObject];
            }else{
                cell = [[[NSBundle mainBundle] loadNibNamed:@"IllnessTableViewCell" owner:self options:nil] firstObject];

            }
        }
        if (indexPath.row == 0) {
            cell.userLabel.text = @"电话";
            [cell.userImage setImage:[UIImage imageNamed:@"百科_电话"]];
            NSArray *array = [[[self.diseaseDic objectForKey:@"data"]objectForKey:@"phone"] componentsSeparatedByString:@"、"]; //从字符、中分隔成元素的数组
            
            cell.detailLabel.text =  [NSString stringWithFormat:@"%@",[array objectAtIndex:0]];
            UIImageView * upImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 0.5)];
            upImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
            [cell addSubview:upImageView];
           
           
            
        }else{
            UIImageView * upImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 0, kScreenWidth - 15, 0.5)];
            upImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
            [cell addSubview:upImageView];
            UIImageView * downImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 45, kScreenWidth, 0.5)];
            if (kScreenWidth == 414) {
                downImageView.frame = CGRectMake(0, 55.5, kScreenWidth, 0.5);
            }else{
                
            }
            downImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
            [cell addSubview:downImageView];
            cell.userLabel.text = @"地址";
            [cell.userImage setImage:[UIImage imageNamed:@"百科_地址"]];
            MyNSLog("%@",[[self.diseaseDic objectForKey:@"data"] objectForKey:@"address"]);
            cell.detailLabel.text = [NSString stringWithFormat:@"%@",[[self.diseaseDic objectForKey:@"data"] objectForKey:@"address"]];
        }
        
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }
    else if (indexPath.section == 3){
        IllnessTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IllnessTableViewCell"];
        if (cell == nil) {
            if (kScreenWidth == 414){
            cell = [[[NSBundle mainBundle] loadNibNamed:@"IllnessTableViewCell" owner:self options:nil] lastObject];
            }else{
                cell = [[[NSBundle mainBundle] loadNibNamed:@"IllnessTableViewCell" owner:self options:nil] firstObject];

            }
        }
        if (indexPath.row == 0) {
            cell.userLabel.text = @"科室";
            [cell.userImage setImage:[UIImage imageNamed:@"百科_医院科室"]];
            cell.detailLabel.text =  [NSString stringWithFormat:@"%@个",[[self.diseaseDic objectForKey:@"data"]objectForKey:@"departmentcount"]];
            UIImageView * upImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 0.5)];
            upImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
            [cell addSubview:upImageView];
        }else if (indexPath.row == 1){
            cell.userLabel.text = @"医生";
            [cell.userImage setImage:[UIImage imageNamed:@"百科_医院医生"]];
            cell.detailLabel.text = [NSString stringWithFormat:@"%@个",[[self.diseaseDic objectForKey:@"data"] objectForKey:@"doctorcount"]];
            UIImageView * upImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 0, kScreenWidth - 15, 0.5)];
            upImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
            [cell addSubview:upImageView];
            
        }else{
            UIImageView * upImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 0, kScreenWidth - 15, 0.5)];
            upImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
            [cell.userImage setImage:[UIImage imageNamed:@"百科_医院点评"]];
            [cell addSubview:upImageView];
            UIImageView * downImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 45, kScreenWidth, 0.5)];
            if(kScreenWidth == 414){
                downImageView.frame = CGRectMake(0, 55.5, kScreenWidth, 0.5);
            }else{
                
            }

            downImageView.backgroundColor = [ClassMethodsViewController colorWithHexString:@"#c8c8c8"];
            [cell addSubview:downImageView];
            cell.userLabel.text = @"点评";
            cell.detailLabel.text = [NSString stringWithFormat:@"%@位",[[self.diseaseDic objectForKey:@"data"] objectForKey:@"commencount"]];
        }
        
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }
    else{
//        static NSString *indent=@"cell";
        HosDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HosDetailTableViewCell"];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"HosDetailTableViewCell" owner:self options:nil] lastObject];
        }
        
        cell.userLabel.text = [NSString stringWithFormat:@"%@",[[self.diseaseDic objectForKey:@"data"] objectForKey:@"hospitalname"]];
        cell.goodLabel.text = [NSString stringWithFormat:@"%@",[[self.diseaseDic objectForKey:@"data"] objectForKey:@"levelname"]];
        cell.userLabel.font = [UIFont systemFontOfSize:TITLE_TEXTLABEL_FOUNT_SIZE];
        cell.goodLabel.font = [UIFont systemFontOfSize:LABEL_FONT_SIZE_CONTENT_13];
        cell.souldLabel.font = [UIFont systemFontOfSize:LABEL_FONT_SIZE_CONTENT_10];
        if ([[[self.diseaseDic objectForKey:@"data"] objectForKey:@"pic"] integerValue] == 0) {
            [cell.userImageView setImage:[UIImage imageNamed:@"hos-l"]];
        }else if ([[[self.diseaseDic objectForKey:@"data"] objectForKey:@"pic"] integerValue] == 1){
            [cell.userImageView setImageWithURL:[NSURL URLWithString:[[self.diseaseDic objectForKey:@"data"] objectForKey:@"picurl"]] placeholderImage:[UIImage imageNamed:@"hos-l"]];
        }
        if ([[[self.diseaseDic objectForKey:@"data"] objectForKey:@"score"]integerValue] > 0 || [[[self.diseaseDic objectForKey:@"data"] objectForKey:@"score"]integerValue] < 1){
            [cell.firstImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            
        }else if ([[[self.diseaseDic objectForKey:@"data"] objectForKey:@"score"]integerValue] >= 1 || [[[self.diseaseDic objectForKey:@"data"] objectForKey:@"score"]integerValue] < 2){
            [cell.firstImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.sectionImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];

        }else if ([[[self.diseaseDic objectForKey:@"data"] objectForKey:@"score"]integerValue] >= 2 || [[[self.diseaseDic objectForKey:@"data"] objectForKey:@"score"]integerValue] < 3){
            [cell.firstImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.sectionImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.thireImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];

        }else if ([[[self.diseaseDic objectForKey:@"data"] objectForKey:@"score"]integerValue] >= 3 || [[[self.diseaseDic objectForKey:@"data"] objectForKey:@"score"]integerValue] < 4){
            [cell.firstImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.sectionImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.thireImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.forImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];

        }else{
            [cell.firstImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.sectionImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.thireImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.forImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];
            [cell.fiveImage setImage:[UIImage imageNamed:@"公用_黄星星.png"]];

        }
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }

}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    if (indexPath.section == 2) {
        
        UILabel * introductionlabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 0,kScreenWidth-15*2 , 20) text:[[self.diseaseDic objectForKeyedSubscript:@"data"] objectForKey:@"introduction"]font:[UIFont systemFontOfSize:LABEL_FONT_SIZE_CONTENT_13] textColor:TITLE_ARTICLE_TEXTFONT_COLOR backgroundColor:[UIColor clearColor] numberOfLines:0 lineSpacing:6];
        return introductionlabel.height + 30;
    }else if (indexPath.section == 0){
        return 65;
    }else{
        if (kScreenWidth == 414){
            return 56;
        }else{
            
            return 46;
        }

    }
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}
//设置段头高
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (self.isload == YES) {
        
        if (section == 2 || section == 3) {
            return 10;
        }else{
            return 0;
        }
    }else{
        return 0;
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section== 2 || section == 3) {
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
        view.backgroundColor = [ClassMethodsViewController colorWithHexString:BACK_BACKGROUNDCOLOR_16];
        return view;
    }else{
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 0)];
        return view;
    }
}
//设置段头高
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (self.isload == YES) {
        
        if (section == 3) {
            return 10;
        }else{
            return 0;
        }
    }else{
        return 0;
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if (section== 3) {
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
        view.backgroundColor = [ClassMethodsViewController colorWithHexString:BACK_BACKGROUNDCOLOR_16];
        return view;
    }else{
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 0)];
        return view;
    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==1) {
        if (indexPath.row==0) {
            //电话
            NSString *regexString  = @"(\\d{11})|(\\d{3}-\\d{3}-\\d{4})|(\\d{3,4}-\\d{7,8}|(\\d{7,8}))";
            NSArray  *matchArray  = [[[self.diseaseDic valueForKey:@"data"] valueForKey:@"phone"] componentsMatchedByRegex:regexString];
            // 匹配结果以数组形式返
            telArray=matchArray;
            UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
            for ( int i=0; i<[matchArray count]; i++) {
                [actionSheet addButtonWithTitle:[matchArray objectAtIndex:i]];
            }
            actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
            
            [actionSheet addButtonWithTitle:@"取消"];
            actionSheet.cancelButtonIndex=actionSheet.numberOfButtons-1;
            [actionSheet showInView:[[[UIApplication sharedApplication] delegate] window]];
        }else
        {
            //地址
            NearbyPathViewController *path=[[NearbyPathViewController alloc]initWithNibName:@"NearbyPathViewController" bundle:[NSBundle mainBundle]];
            path.lattited=[[[self.diseaseDic valueForKey:@"data"] valueForKey:@"lat"] floatValue];
            path.lngtited=[[[self.diseaseDic valueForKey:@"data"] valueForKey:@"lng"] floatValue];
            path.isFromHosp=YES;
            [self.navigationController pushViewController:path animated:YES];
        }
    }
    else if (indexPath.section==3)
    {
        if (indexPath.row==0) {
            //科室列表
            DepartmentViewController * depart = [[DepartmentViewController alloc] init];
           
            depart.hospitalid = [self.diseaseDic[@"data"] objectForKey:@"hospitalid"];
            MyNSLog("百科-医院-科室-》向科室列表传医院hospitalid %@",depart.hospitalid );
            [self.navigationController pushViewController:depart animated:YES];
            
        }else if (indexPath.row==1)
        {
            /**
             *  医生列表
             */
            RegDoctorListViewController * docList = [[RegDoctorListViewController alloc] init];
            docList.regHosDepartDic = @{@"hospitalid":[self.diseaseDic[@"data"] objectForKey:@"hospitalid"]};
            [self.navigationController pushViewController:docList animated:YES];
        }
        else
        {
            EncyMyCommentViewController * list = [[EncyMyCommentViewController alloc] init];
            NSString * hospitalid = [self.diseaseDic[@"data"] objectForKey:@"hospitalid"];
            list.commentKey = @"hospitalid";
            list.commentId = hospitalid;
            list.type = @"1";
            
            [self.navigationController pushViewController:list animated:YES];
            
        }
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//打电话代理
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == [actionSheet cancelButtonIndex]) {
        return;
    }
    else {
        //NSLog(@"打电话");
        NSString *number = [telArray objectAtIndex:buttonIndex];
        NSString *num = [[NSString alloc] initWithFormat:@"telprompt://%@",number];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:num]];
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
